package model

import "gopkg.in/go-playground/validator.v8"

type User struct {
	Name string `form:"name" binding:"required"`
	Pwd string `form:"pwd" binding:"required"`
}

func (r *User) GetError(err validator.ValidationErrors) string {
	if val, exist := err["User.Name"]; exist {
		if val.Field == "Name" {
			switch val.Tag {
			case "required":
				return "用户名不能为空!!"
			}
		}
	}
	if val, exist := err["User.Pwd"]; exist {
		if val.Field == "Pwd" {
			switch val.Tag {
			case "required":
				return "密码不能为空!!"
			}
		}
	}
	return "参数错误，请检查"
}
